<template>
  <div>
    <div class="popWin" :style="{ zIndex: zIndex }" v-if="show">
      <div class="popWinBg"></div>
      <div class="popWinMain" ref="popWinMain" :style="{ height: this.height }">
        <bg></bg>
        <div class="popWinMainInner" v-if="showInner">
          <div class="search">
            <el-input style="width:100%" placeholder="请输入项目名称" suffix-icon="el-icon-search" v-model="input"
              @keyup.enter.native="handleSubmit()"></el-input>
          </div>
          <div class="slot">
            <el-table :data="tableDataList" height="100%" style="width: 100%" stripe @row-click="handleRowClick">
              <el-table-column label="项目编号" align="center" prop="itemNo">
                <template slot-scope="scope">
                  <span class="bs">{{ scope.row.itemNo }}</span>
                </template>
              </el-table-column>
              <el-table-column label="项目名称" show-overflow-tooltip prop="itemName" align="center">
              </el-table-column>
              <el-table-column label="项目状态" prop="projectType" align="center">
                <template slot-scope="scope">
                  <span class="ps" :class="{ps1:scope.row.itemStatus===2,ps2:scope.row.itemStatus===0,ps3:scope.row.itemStatus===1}">
                    {{ scope.row.itemStatus==0?'未开始':scope.row.itemStatus==1?'进行中':'已完成' }}
                  </span>
                </template>
              </el-table-column>
              <el-table-column label="项目类型" prop="itemType" align="center">
              </el-table-column>
              <el-table-column label="项目负责人" prop="itemLeader" align="center">
              </el-table-column>
              <el-table-column label="合同签订额" prop="itemAmount" align="center">
                <template slot-scope="scope">
                  <span class="bs">{{ scope.row.itemAmount }}</span>
                </template>
              </el-table-column>
              <el-table-column label="店铺名称" show-overflow-tooltip prop="shop" align="center">
              </el-table-column>
            </el-table>
            <div style="width: 100%;text-align: right;margin-top: 10px">
              <el-pagination background layout="prev, pager, next, jumper" :total="total" @current-change="curChange">
              </el-pagination>
            </div>
          </div>
          <div class="footerLine"></div>
          <div class="footerBut">
            <div class="footerButItem" @click="getHide"><span>取消</span></div>
            <div class="footerButItem" @click="getConfirm"><span>确定</span></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import gsap from 'gsap'
import bg from './bg/index.vue'
import bus from '@/eventBus'
import { itemGetAll} from '@/api/home.js'

export default {
  data() {
    return {
      show: false,
      showInner: false,
      tableDataList: [],
      obj: {},
      tableData: {},
      input: '',
      pageSize:20,
      page:1,
      total:0
    }
  },
  components: { bg },
  mounted() {
    this.getTableDataList()
    if (this.appendToBody) {
      const bodyElement = document.querySelector('body')
      bodyElement.appendChild(this.$el)
    }
  },
  props: {
    title: {
      type: String,
      default() {
        return '标题'
      }
    },
    width: {
      type: String,
      default() {
        return '85%'
      }
    },
    height: {
      type: String,
      default() {
        return '659px'
      }
    },
    // 弹窗层级,默认最大值
    zIndex: {
      type: Number,
      default: 147
    },
    // 是否将组件插入到body中 默认true
    appendToBody: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    curChange(v){
      this.page = v
      this.getTableDataList()
    },
    handleRowClick(row, column, event) {
      this.obj = row
      bus.$emit('share', row)
    },
    handleSubmit() {
      console.log(this.input);
    },
    async getTableDataList() {
      let obj = {
        page: this.page,
        pageSize: this.pageSize
      }
      await itemGetAll(obj).then(res => {
        if (res.code == 200) {
          this.tableDataList = res.data.list
          this.total = res.data.total
          this.tableDataList.forEach((item, index) => {
            item.id = index
          })
        } else {
          this.$message({
            message: res.msg,
            type: 'error'
          })
        }
      }).catch(err => {
        console.log(err)
      })
    },
    getShow() {
      var that = this
      that.show = true
      that.$nextTick(() => {
        gsap.to(this.$refs.popWinMain, {
          duration: 1,
          width: '1200px',
          onComplete: () => {
            this.showInner = true
          }
        })
      })
    },
    getConfirm() {
      this.getHide()
      this.$emit('confirm', this.obj)
      bus.$emit('share', this.obj)
    },
    getHide() {
      this.showInner = false
      this.$nextTick(() => {
        gsap.to(this.$refs.popWinMain, {
          duration: 1,
          width: '0%',
          onComplete: () => {
            this.show = false
          }
        })
      })
      this.tableData = {}
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-pagination__jump{
  color: #fff;
}
::v-deep .el-pager li:not(.disabled).active{
  background-color: #1455aa !important;
}

.popWinBg {
  position: fixed;
  z-index: 8;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  height: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: initial;
}

.popWin {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  position: fixed;
  z-index: 10;
  width: 100%;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  pointer-events: none;

}

.popWinMain {
  pointer-events: initial;
  position: relative;
  overflow: hidden;
  width: 0%;
  max-width: 1642px;
  height: 85%;
  max-height: 1004px;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  //background: url("./bg/assets/bg.png") no-repeat;
  //background-size: 100% 100%;

  .popClose {
    position: absolute;
    right: 10px;
    top: 10px;
    background: url("./assets/icon_close.png") no-repeat;
    width: 16px;
    height: 16px;
    background-size: 100% 100%;
    cursor: pointer;
    z-index: 1;
    //transform: rotateX(180deg);
  }

  .popWinMainInner {
    position: relative;
    width: calc(100% - 40px);
    height: calc(100% - 0px);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap;
    flex-direction: column;
    align-content: flex-start;

    .search {
      width: 100%;
      margin-top: 40px;
      padding: 0 20px;
      box-sizing: border-box;

      ::v-deep .el-input__inner {
        background-color: transparent !important;
        border: 1px solid #1455aa !important;
        color: #fff !important;
      }
    }

    .slot {
      position: relative;
      width: 100%;
      height: calc(100% - 170px);
      margin-top: 10px;
      overflow: auto;
      padding: 20px;
      box-sizing: border-box;
      display: flex;
      justify-content: flex-start;
      align-items: flex-start;
      flex-wrap: nowrap;
      flex-direction: column;
      align-content: flex-start;
      //background: red;
      .ps {
        width: 68px;
        height: 26px;
        margin: auto;
        border-radius: 2px 2px 2px 2px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: nowrap;
        flex-direction: row;
        align-content: flex-start;
        font-size: 14px;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
      }
      .ps1{
        background: rgba(0, 194, 255, 0.2);
        color: #00C2FF;
      }
      .ps2{
        background: rgba(255, 184, 1, 0.2);
        color: rgba(255, 184, 1, 1);
      }
      .ps3{
        background: rgba(38, 255, 98, 0.2);
        color: rgba(38, 255, 98,1);
      }
    }
  }
}

.footerLine {
  background: url("./assets/footerLine.png") no-repeat;
  background-size: 100% 100%;
  height: 20px;
  width: 100%;
  position: relative;
  bottom: 0;
  margin-top: -30px;
}

.footerBut {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
  align-content: flex-start;
  width: 100%;
  height: 100px;

  .footerButItem {
    background: url("./assets/butbg.png") no-repeat;
    background-size: 100% 100%;
    width: 130px;
    height: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-left: 45px;
    margin-right: 45px;
    cursor: pointer;

    span {
      font-size: 18px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: #89ADCE;
      letter-spacing: 20px;
      text-indent: 20px;
    }
  }

  .footerButItem:hover {
    background: url("./assets/butbgActive.png") no-repeat;
    background-size: 100% 100%;
    width: 130px;
    height: 46px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    margin-left: 45px;
    margin-right: 45px;
    cursor: pointer;

    span {
      font-size: 18px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      color: rgba(71, 200, 255, 1);
      letter-spacing: 20px;
      text-indent: 20px;
    }
  }
}
</style>
<style lang="scss" scoped>
.popWinMainInner {
  position: relative;
  height: 100%;
  width: 100%;

  .lx {
    width: 68px;
    height: 26px;
    margin: auto;
    background: rgba(#47C8FF, 0.2);
    border-radius: 2px 2px 2px 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    align-content: flex-start;
    font-size: 14px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    color: #00FFFF;
  }

  .el-table,
  .el-table__expanded-cell {
    background: none !important;
  }

  .el-table tr {
    background: #053275 !important;
  }

  .el-table td.el-table__cell div {
    color: rgba(184, 204, 255, 1) !important;
  }

  .el-table td.el-table__cell,
  .el-table th.el-table__cell.is-leaf {
    border: none !important;
  }

  .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
    background: #093b7d;

    .lx {
      width: 68px;
      height: 26px;
      margin: auto;
      border-radius: 2px 2px 2px 2px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      align-content: flex-start;
      font-size: 14px;
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      background: rgba(255, 184, 1, 0.2);
      color: rgba(255, 184, 1, 1);
    }
  }

  .el-table--enable-row-hover .el-table__body tr:hover>td {
    background: #0c4693 !important;
  }

  .el-table th.el-table__cell {
    background: #1455aa !important;
    color: rgba(71, 200, 255, 1);
  }

  .el-table--border::after,
  .el-table--group::after,
  .el-table::before {
    background-color: rgba(#EBEEF5, 0);
  }

  //纵向滚动条
  .is-scrolling-none::-webkit-scrollbar {
    width: 6px;
    height: 200px;
  }

  .bs {
    font-size: 14px;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    color: #FFB801;
  }

  /*滚动条滑块*/
  .is-scrolling-none::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    border-radius: 10px;
    box-shadow: inset 0 0 5px #189abc;
    background: #115091;
  }

  /*滚动条轨道*/
  .is-scrolling-none::-webkit-scrollbar-track {
    /*滚动条里面轨道*/
    box-shadow: inset 0 0 5px #1f4962;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0);
  }

  //横向
  //横向horizontal

  .is-scrolling-left::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  /*滚动条滑块*/
  .is-scrolling-left::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    background: #56B5FF;
    border-radius: 5px;
  }

  /*滚动条轨道*/
  .is-scrolling-left::-webkit-scrollbar-track {}

  /*滚动条轨道*/
  .is-scrolling-left::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

  //横向滚动右侧
  .is-scrolling-right::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  /*滚动条滑块*/
  .is-scrolling-right::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    background: #56B5FF;
    border-radius: 5px;
  }

  /*滚动条轨道*/
  .is-scrolling-right::-webkit-scrollbar-track {}

  /*滚动条轨道*/
  .is-scrolling-right::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

  //横向滚动中部
  .is-scrolling-middle::-webkit-scrollbar {
    width: 100%;
    height: 10px;
  }

  /*滚动条滑块*/
  .is-scrolling-middle::-webkit-scrollbar-thumb {
    /*滚动条里面小方块*/
    background: #56B5FF;
    border-radius: 5px;
  }

  /*滚动条轨道*/
  .is-scrolling-middle::-webkit-scrollbar-track {}

  /*滚动条轨道*/
  .is-scrolling-middle::-webkit-scrollbar-track-piece {
    background-color: rgba(2, 6, 23, 0);
  }

}
</style>
